package com.cty.ioc_03;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {
//    @Autowired(required = false) //作用:在ioc中寻找该类型对象，找到即赋值，未找到报错,不再用setter方法
//    //佛系装配(组件数量可以为0或者1或者更多)，
//    //将Autowired里的required对象改为false，但下面会出现空指针异常【不推荐】
//    @Qualifier(value = "userServiceImpl")
    @Resource(name = "userServiceImpl")
    private UserService userService;
    public void show() {
        userService.show();
    }
}
